package com.liushuyv.calculator.bll;

/*
 **@Author:刘淑钰
 *
 **Created on 2020/11/28
 */
public class Operation implements IOperation {
    private int a;
    private int b;

    public void setValue(int a,int b) throws Exception {
    /*先进行数据合法性检查*/
        if(a>1000||b>1000){
            throw new Exception("数据范围超限");
        }else{
            this.a=a;
            this.b=b;//和c++不同的是在这里访问自身元素用.而不是箭头
        }
    }

    @Override //注解，建议保留
    public int add() {
        return a+b;
    }

    @Override
    public int sub() {
        return a-b;
    }
}
